package kr.hkit.androidcomplete02.ch17;

import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class ActEdit extends Activity {
	EditText edit;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_actedit);
		
		edit = (EditText) findViewById(R.id.ch17_actedit_edit);
		
		Intent intent = getIntent();
		String text = intent.getStringExtra("textIn");
		if(text != null){
			edit.setText(text);
		}
	}
	
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.ch17_actedit_btnok:
			Intent intent = new Intent();
			intent.putExtra("textOut", edit.getText().toString());
			setResult(RESULT_OK, intent);
			finish();
			break;
		case R.id.ch17_actedit_cancel:
			setResult(RESULT_CANCELED);
			finish();
			break;
		}
	}
}
